References
A reference is a phrase that specifies one or more objects. You use references to identify objects within applications. An example of a reference is
word 5 of paragraph 10 of document "Work in Progress"which specifies a word object in the document named Work in Progress.A reference describes what type of object you're looking for, where to look for the object, and how to distinguish the object from other objects of the same type. These three types of information--the class, or type; the container, or location; and the reference form, or distinguishing information--allow you to specify any object of an application.
In general, you list the class and distinguishing information at the beginning of a reference, followed by the container. In the previous example, the class of the object is
word
. The container is the phraseparagraph 10 of document "Work in Progress"
. The distinguishing information (the reference form) is the combination of the class,word
, and an index value, 5, which together indicate the fifth word.References allow you to identify objects in a flexible and intuitive way. Just as there might be several ways to identify an object on the desktop, AppleScript has different reference forms that allow you to specify the same object in different ways. For example, here's another way to specify the fifth word of
a document:
word after word 4 of document "Work in Progress"To write effective scripts, you should be familiar with AppleScript's reference forms and know how to use containers and reference forms to identify the objects you want to manipulate. The sections that follow describe containers and reference forms.
Subtopics
- Containers
- Complete and Partial References